package com.online.taxi.passenger.controller;

import com.online.taxi.passenger.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.online.taxi.common.dto.ResponseResult;
import com.online.taxi.passenger.request.UserAuthRequest;

/**
 * @author oi
 */
@RestController
@RequestMapping("/auth")
public class AuthController {

  @Autowired
  AuthService authService;

  @PostMapping("/login")
  public ResponseResult login(@RequestBody @Validated UserAuthRequest userAuthRequest) {

    String passengerPhone = userAuthRequest.getPassengerPhone();
    String code = userAuthRequest.getCode();

    return authService.auth(passengerPhone, code);

  }

}
